package com.ttg.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.HashMap;
import java.util.Map;

/**
 * 均值类型
 *
 * @author h
 * @date 2023/07/05 14:52:11
 **/
public enum RealAverageEnum {


    /**
     * 年
     */
    YEAR(1, "年"),
    /**
     * 季
     */
    QUARTER(2, "季"),
    /**
     * 月
     */
    MONTH(3, "月"),
    /**
     * 周
     */
    WEEK(4, "周");


    @EnumValue
    @JsonValue
    private Integer value;
    private String desc;

    RealAverageEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    private static final Map<Integer, RealAverageEnum> VALUES = new HashMap<>();

    static {
        for (final RealAverageEnum type : RealAverageEnum.values()) {
            RealAverageEnum.VALUES.put(type.getValue(), type);
        }
    }

    @JsonCreator
    public static RealAverageEnum of(Integer code) {
        return RealAverageEnum.VALUES.get(code);
    }

}
